<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>盒模型-外边距塌陷问题</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    .box1 {
      /* 解决1 删除margin-top 推荐 */
      padding-top: 50px;
      width: 320px;
      height: 320px;
      background-color: #ff0;
      /* 解决2 不删除margin-top */
      /* overflow: hidden; */
      /* 解决3 不删除margin-top */
      /* border-top: 1px solid #000; */
    }

    .box1>.box2 {
      /* margin-top: 50px; */
      width: 150px;
      height: 150px;
      background-color: #00f;
    }
  </style>
</head>

<body>
  <div class="box1">
    <div class="box2"></div>
  </div>
</body>

</html>